package com.xcity.game.peakroad.model.response;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import com.xcity.db.entity.Player;
import com.xcity.game.combat.attr.CombatAttribute;
import com.xcity.game.item.ItemInfo;
import com.xcity.game.peakroad.model.PeakRoadInstance;
import com.xcity.game.peakroad.template.PeakRoadTemplate;

/**
 * 奖励层
 * @author yang.li
 *
 */
public class RewardFloorSub extends FloorSub {

	public List<PeakRoadBuff> buffs = Collections.emptyList(); // 可选的奖励buff
	public List<ItemInfo> items = Collections.emptyList(); // 可选的奖励物品
	
	public static final byte STATE_CAN_NOT_REWARD = 0; // 不能领取buff或宝箱
	public static final byte STATE_CAN_GET_BUFF = 1; // 可领取buff
	public static final byte STATE_CAN_GET_ITEM = 2; // 可领取宝箱
	public static final byte STATE_REWARDED = 3; // 已领取完buff和宝箱
	
	public RewardFloorSub(Player player, PeakRoadTemplate refer) {
		int currentFloor = player.getPeakRoadInstance().getFloor();
		int floor = refer.getId();
		if (floor < currentFloor) {
			state = STATE_REWARDED;
		} else if (floor > currentFloor) {
			state = STATE_CAN_NOT_REWARD;
		} else {
			state = player.getPeakRoadInstance().hasState(PeakRoadInstance.STATE_REWARD_BUFF_MASK) ? STATE_CAN_GET_ITEM : STATE_CAN_GET_BUFF;
		}
		CombatAttribute[] attrs = refer.getWrappedBuffs();
		if (attrs != null) {
			buffs = new ArrayList<PeakRoadBuff>(attrs.length);
			for (int i = 0; i < attrs.length; i++) {
				CombatAttribute attr = attrs[i];
				buffs.add(new PeakRoadBuff(i, attr));
			}
		}
		// do not handle the items
	}
	
}
